home *** CD-ROM | disk | FTP | other *** search
/ Chip 2004 December / 2004-12 CHIP.iso / Narzedzia systemowe / Inno Setup 5.0.4 Beta / isetup-5.0.4-beta.exe / {app} / Examples / CodeClasses.iss (.txt) < prev    next >
Encoding:
Inno Setup Script  |  2004-08-02  |  10.9 KB  |  254 lines

  1. ; -- CodeClasses.iss --
  2. ; This script shows how to use the WizardForm object and the various VCL classes.
  3. [Setup]
  4. AppName=My Program
  5. AppVerName=My Program version 1.5
  6. CreateAppDir=no
  7. DisableProgramGroupPage=yes
  8. DefaultGroupName=My Program
  9. UninstallDisplayIcon={app}\MyProg.exe
  10. WindowVisible=yes
  11. [Files]
  12. Source: compiler:WizModernSmallImage.bmp; Flags: dontcopy
  13. [Code]
  14. procedure ButtonOnClick(Sender: TObject);
  15. begin
  16.   MsgBox('You clicked the button!', mbInformation, mb_Ok);
  17. procedure FormButtonOnClick(Sender: TObject);
  18.   Form: TSetupForm;
  19.   OKButton, CancelButton: TButton;
  20. begin
  21.   Form := CreateCustomForm();
  22.   try
  23.     Form.ClientWidth := ScaleX(256);
  24.     Form.ClientHeight := ScaleY(256);
  25.     Form.Caption := 'TSetupForm';
  26.     Form.CenterInsideControl(WizardForm, False);
  27.     OKButton := TButton.Create(Form);
  28.     OKButton.Parent := Form;
  29.     OKButton.Width := ScaleX(75);
  30.     OKButton.Height := ScaleY(23);
  31.     OKButton.Left := Form.ClientWidth - ScaleX(75 + 6 + 75 + 10);
  32.     OKButton.Top := Form.ClientHeight - ScaleY(23 + 10);
  33.     OKButton.Caption := 'OK';
  34.     OKButton.ModalResult := mrOk;
  35.     CancelButton := TButton.Create(Form);
  36.     CancelButton.Parent := Form;
  37.     CancelButton.Width := ScaleX(75);
  38.     CancelButton.Height := ScaleY(23);
  39.     CancelButton.Left := Form.ClientWidth - ScaleX(75 + 10);
  40.     CancelButton.Top := Form.ClientHeight - ScaleY(23 + 10);
  41.     CancelButton.Caption := 'Cancel';
  42.     CancelButton.ModalResult := mrCancel;
  43.     CancelButton.Cancel := True;
  44.     Form.ActiveControl := OKButton;
  45.     if Form.ShowModal() = mrOk then
  46.       MsgBox('You clicked OK.', mbInformation, MB_OK);
  47.   finally
  48.     Form.Free();
  49.   end;
  50. procedure CreateTheWizardPages;
  51.   Page: TWizardPage;
  52.   Button, FormButton: TButton;
  53.   CheckBox: TCheckBox;
  54.   Edit: TEdit;
  55.   PasswordEdit: TPasswordEdit;
  56.   Memo: TMemo;
  57.   Lbl, ProgressBarLabel: TLabel;
  58.   ComboBox: TComboBox;
  59.   ListBox: TListBox;
  60.   StaticText: TNewStaticText;
  61.   ProgressBar: TNewProgressBar;
  62.   CheckListBox, CheckListBox2: TNewCheckListBox;
  63.   FolderTreeView: TFolderTreeView;
  64.   BitmapImage, BitmapImage2, BitmapImage3: TBitmapImage;
  65.   BitmapFileName: String;
  66.   RichEditViewer: TRichEditViewer;
  67. begin
  68.   { TButton and others }
  69.   Page := CreateCustomPage(wpWelcome, 'Custom wizard page controls', 'TButton and others');
  70.   Button := TButton.Create(Page);
  71.   Button.Width := ScaleX(75);
  72.   Button.Height := ScaleY(23);
  73.   Button.Caption := 'TButton';
  74.   Button.OnClick := @ButtonOnClick;
  75.   Button.Parent := Page.Surface;
  76.   CheckBox := TCheckBox.Create(Page);
  77.   CheckBox.Top := Button.Top + Button.Height + ScaleY(8);
  78.   CheckBox.Width := Page.SurfaceWidth;
  79.   CheckBox.Height := ScaleY(17);
  80.   CheckBox.Caption := 'TCheckBox';
  81.   CheckBox.Checked := True;
  82.   CheckBox.Parent := Page.Surface;
  83.   Edit := TEdit.Create(Page);
  84.   Edit.Top := CheckBox.Top + CheckBox.Height + ScaleY(8);
  85.   Edit.Width := Page.SurfaceWidth div 2 - ScaleX(8);
  86.   Edit.Text := 'TEdit';
  87.   Edit.Parent := Page.Surface;
  88.   PasswordEdit := TPasswordEdit.Create(Page);
  89.   PasswordEdit.Left := Page.SurfaceWidth - Edit.Width;
  90.   PasswordEdit.Top := CheckBox.Top + CheckBox.Height + ScaleY(8);
  91.   PasswordEdit.Width := Edit.Width;
  92.   PasswordEdit.Text := 'TPasswordEdit';
  93.   PasswordEdit.Parent := Page.Surface;
  94.   Memo := TMemo.Create(Page);
  95.   Memo.Top := Edit.Top + Edit.Height + ScaleY(8);
  96.   Memo.Width := Page.SurfaceWidth;
  97.   Memo.Height := ScaleY(89);
  98.   Memo.ScrollBars := ssVertical;
  99.   Memo.Text := 'TMemo';
  100.   Memo.Parent := Page.Surface;
  101.   Lbl := TLabel.Create(Page);
  102.   Lbl.Top := Memo.Top + Memo.Height + ScaleY(8);
  103.   Lbl.Caption := 'TLabel';
  104.   Lbl.AutoSize := True;
  105.   Lbl.Parent := Page.Surface;
  106.   FormButton := TButton.Create(Page);
  107.   FormButton.Top := Lbl.Top + Lbl.Height + ScaleY(8);
  108.   FormButton.Width := ScaleX(75);
  109.   FormButton.Height := ScaleY(23);
  110.   FormButton.Caption := 'TSetupForm';
  111.   FormButton.OnClick := @FormButtonOnClick;
  112.   FormButton.Parent := Page.Surface;
  113.   { TComboBox and others }
  114.   Page := CreateCustomPage(Page.ID, 'Custom wizard page controls', 'TComboBox');
  115.   ComboBox := TComboBox.Create(Page);
  116.   ComboBox.Width := Page.SurfaceWidth;
  117.   ComboBox.Parent := Page.Surface;
  118.   ComboBox.Items.Add('TComboBox');
  119.   ComboBox.ItemIndex := 0;
  120.   ListBox := TListBox.Create(Page);
  121.   ListBox.Top := ComboBox.Top + ComboBox.Height + ScaleY(8);
  122.   ListBox.Width := Page.SurfaceWidth;
  123.   ListBox.Height := ScaleY(97);
  124.   ListBox.Parent := Page.Surface;
  125.   ListBox.Items.Add('TListBox');
  126.   ListBox.ItemIndex := 0;
  127.   StaticText := TNewStaticText.Create(Page);
  128.   StaticText.Top := ListBox.Top + ListBox.Height + ScaleY(8);
  129.   StaticText.Caption := 'TNewStaticText';
  130.   StaticText.AutoSize := True;
  131.   StaticText.Parent := Page.Surface;
  132.   ProgressBarLabel := TLabel.Create(Page);
  133.   ProgressBarLabel.Top := StaticText.Top + StaticText.Height + ScaleY(8);
  134.   ProgressBarLabel.Caption := 'TNewProgressBar';
  135.   ProgressBarLabel.AutoSize := True;
  136.   ProgressBarLabel.Parent := Page.Surface;
  137.   ProgressBar := TNewProgressBar.Create(Page);
  138.   ProgressBar.Left := ProgressBarLabel.Width + ScaleX(8);
  139.   ProgressBar.Top := ProgressBarLabel.Top;
  140.   ProgressBar.Width := Page.SurfaceWidth - ProgressBar.Left;
  141.   ProgressBar.Height := ProgressBarLabel.Height + ScaleY(8);
  142.   ProgressBar.Parent := Page.Surface;
  143.   ProgressBar.Position := 25;
  144.   { TNewCheckListBox }
  145.   Page := CreateCustomPage(Page.ID, 'Custom wizard page controls', 'TNewCheckListBox');
  146.   CheckListBox := TNewCheckListBox.Create(Page);
  147.   CheckListBox.Width := Page.SurfaceWidth;
  148.   CheckListBox.Height := ScaleY(97);
  149.   CheckListBox.Flat := True;
  150.   CheckListBox.Parent := Page.Surface;
  151.   CheckListBox.AddCheckBox('TNewCheckListBox', '', 0, True, True, False, True, nil);
  152.   CheckListBox.AddRadioButton('TNewCheckListBox', '', 1, True, True, nil);
  153.   CheckListBox.AddRadioButton('TNewCheckListBox', '', 1, False, True, nil);
  154.   CheckListBox.AddCheckBox('TNewCheckListBox', '', 0, True, True, False, True, nil);
  155.   CheckListBox2 := TNewCheckListBox.Create(Page);
  156.   CheckListBox2.Top := CheckListBox.Top + CheckListBox.Height + ScaleY(8);
  157.   CheckListBox2.Width := Page.SurfaceWidth;
  158.   CheckListBox2.Height := ScaleY(97);
  159.   CheckListBox2.BorderStyle := bsNone;
  160.   CheckListBox2.ParentColor := True;
  161.   CheckListBox2.MinItemHeight := WizardForm.TasksList.MinItemHeight;
  162.   CheckListBox2.ShowLines := False;
  163.   CheckListBox2.WantTabs := True;
  164.   CheckListBox2.Parent := Page.Surface;
  165.   CheckListBox2.AddGroup('TNewCheckListBox', '', 0, nil);
  166.   CheckListBox2.AddRadioButton('TNewCheckListBox', '', 0, True, True, nil);
  167.   CheckListBox2.AddRadioButton('TNewCheckListBox', '', 0, False, True, nil);
  168.   { TFolderTreeView }
  169.   Page := CreateCustomPage(Page.ID, 'Custom wizard page controls', 'TFolderTreeView');
  170.   FolderTreeView := TFolderTreeView.Create(Page);
  171.   FolderTreeView.Width := Page.SurfaceWidth;
  172.   FolderTreeView.Height := Page.SurfaceHeight;
  173.   FolderTreeView.Parent := Page.Surface;
  174.   FolderTreeView.Directory := ExpandConstant('{src}');
  175.   { TBitmapImage }
  176.   Page := CreateCustomPage(Page.ID, 'Custom wizard page controls', 'TBitmapImage');
  177.   BitmapFileName := ExpandConstant('{tmp}\WizModernSmallImage.bmp');
  178.   ExtractTemporaryFile(ExtractFileName(BitmapFileName));
  179.   BitmapImage := TBitmapImage.Create(Page);
  180.   BitmapImage.AutoSize := True;
  181.   BitmapImage.Bitmap.LoadFromFile(BitmapFileName);
  182.   BitmapImage.Parent := Page.Surface;
  183.   BitmapImage2 := TBitmapImage.Create(Page);
  184.   BitmapImage2.BackColor := $400000;
  185.   BitmapImage2.Bitmap := BitmapImage.Bitmap;
  186.   BitmapImage2.Center := True;
  187.   BitmapImage2.Left := BitmapImage.Width + 10;
  188.   BitmapImage2.Height := 2*BitmapImage.Height;
  189.   BitmapImage2.Width := 2*BitmapImage.Width;
  190.   BitmapImage2.Parent := Page.Surface;
  191.   BitmapImage3 := TBitmapImage.Create(Page);
  192.   BitmapImage3.Bitmap := BitmapImage.Bitmap;
  193.   BitmapImage3.Stretch := True;
  194.   BitmapImage3.Left := 3*BitmapImage.Width + 20;
  195.   BitmapImage3.Height := 4*BitmapImage.Height;
  196.   BitmapImage3.Width := 4*BitmapImage.Width;
  197.   BitmapImage3.Parent := Page.Surface;
  198.   { TRichViewer }
  199.   Page := CreateCustomPage(Page.ID, 'Custom wizard page controls', 'TRichViewer');
  200.   RichEditViewer := TRichEditViewer.Create(Page);
  201.   RichEditViewer.Width := Page.SurfaceWidth;
  202.   RichEditViewer.Height := Page.SurfaceHeight;
  203.   RichEditViewer.Parent := Page.Surface;
  204.   RichEditViewer.ScrollBars := ssVertical;
  205.   RichEditViewer.UseRichEdit := True;
  206.   RichEditViewer.RTFText := '{\rtf1\ansi\ansicpg1252\deff0\deflang1043{\fonttbl{\f0\fswiss\fcharset0 Arial;}}{\colortbl ;\red255\green0\blue0;\red0\green128\blue0;\red0\green0\blue128;}\viewkind4\uc1\pard\f0\fs20 T\cf1 Rich\cf2 Edit\cf3 Viewer\cf0\par}';
  207.   RichEditViewer.ReadOnly := True;
  208. procedure AboutButtonOnClick(Sender: TObject);
  209. begin
  210.   MsgBox('This demo shows some features of the WizardForm object and the various VCL classes.', mbInformation, mb_Ok);
  211. procedure URLLabelOnClick(Sender: TObject);
  212.   ErrorCode: Integer;
  213. begin
  214.   ShellExec('open', 'http://www.innosetup.com', '', '', SW_SHOWNORMAL, ewNoWait, ErrorCode);
  215. procedure InitializeWizard();
  216.   AboutButton, CancelButton: TButton;
  217.   URLLabel: TNewStaticText;
  218.   BackgroundBitmapImage: TBitmapImage;
  219.   BackgroundBitmapText: TNewStaticText;
  220. begin
  221.   { Custom wizard pages }
  222.   CreateTheWizardPages;
  223.   { Other custom controls }
  224.   CancelButton := WizardForm.CancelButton;
  225.   AboutButton := TButton.Create(WizardForm);
  226.   AboutButton.Left := WizardForm.ClientWidth - CancelButton.Left - CancelButton.Width;
  227.   AboutButton.Top := CancelButton.Top;
  228.   AboutButton.Width := CancelButton.Width;
  229.   AboutButton.Height := CancelButton.Height;
  230.   AboutButton.Caption := '&About...';
  231.   AboutButton.OnClick := @AboutButtonOnClick;
  232.   AboutButton.Parent := WizardForm;
  233.   URLLabel := TNewStaticText.Create(WizardForm);
  234.   URLLabel.Caption := 'www.innosetup.com';
  235.   URLLabel.Cursor := crHand;
  236.   URLLabel.OnClick := @URLLabelOnClick;
  237.   URLLabel.Parent := WizardForm;
  238.   { Alter Font *after* setting Parent so the correct defaults are inherited first }
  239.   URLLabel.Font.Style := URLLabel.Font.Style + [fsUnderline];
  240.   URLLabel.Font.Color := clBlue;
  241.   URLLabel.Top := AboutButton.Top + AboutButton.Height - URLLabel.Height - 2;
  242.   URLLabel.Left := AboutButton.Left + AboutButton.Width + ScaleX(20);
  243.   BackgroundBitmapImage := TBitmapImage.Create(MainForm);
  244.   BackgroundBitmapImage.Left := 50;
  245.   BackgroundBitmapImage.Top := 100;
  246.   BackgroundBitmapImage.AutoSize := True;
  247.   BackgroundBitmapImage.Bitmap := WizardForm.WizardBitmapImage.Bitmap;
  248.   BackgroundBitmapImage.Parent := MainForm;
  249.   BackgroundBitmapText := TNewStaticText.Create(MainForm);
  250.   BackgroundBitmapText.Left := BackgroundBitmapImage.Left;
  251.   BackgroundBitmapText.Top := BackgroundBitmapImage.Top + BackgroundBitmapImage.Height + ScaleY(8);
  252.   BackgroundBitmapText.Caption := 'TBitmapImage';
  253.   BackgroundBitmapText.Parent := MainForm;
  254.